window.onload = function() {

	oTab = document.getElementById('tab');
	aBtn = oTab.getElementsByTagName('button');
	aDiv = oTab.getElementsByTagName('div');

	initTab();
};

var oTab = null;
var aBtn = null;
var aDiv = null;

function initTab() {
	for(var i = 0; i < aBtn.length; i++) {
		aBtn[i].index = i;
		aBtn[i].addEventListener('click', doTab, false);
	}
}

function doTab() {
	for(var i = 0; i < aBtn.length; i++) {
		aBtn[i].className = '';
		aDiv[i].style.display = 'none';
	}
	this.className = 'active';
	aDiv[this.index].style.display = 'block';
}
